import 'package:dynamic_forms/dynamic_forms.dart';

import 'check_box.dart';

class CheckBoxParser extends ElementParser<DyCheckBox> {
  @override
  String get name => "checkBox";

  @override
  DyCheckBox parse(
      ParserNode parserNode, FormElement parent, ElementParserFunction parser) {
    var checkBox = DyCheckBox();
    checkBox.fillCheckBox(
      id: parserNode.getPlainStringValue("id"),
      isVisible: parserNode.getIsVisible(),
      parent: parserNode.getParentValue(parent),
      value: parserNode.getValue(
        DyCheckBox.valuePropertyName,
        ParserNode.convertToBool,
        ParserNode.defaultFalse,
        isImmutable: false,
      ),
      title: parserNode.getStringValue(DyCheckBox.titlePropertyName),
      attribute: parserNode.getStringValue(DyCheckBox.attributePropertyName),
    );
    return checkBox;
  }
}
